Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    toastText: {            // 属性名
      type: String,
      value: '内容'
    },
    icon: {
      type: String,
      value: 'warning'
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    toastShow: false,
    time: 2500,
    warningImgSrc: '/images/gantan.png',
    successImgSrc: '/images/success.png',
  },
  /**
   * 组件的方法列表
   */
  methods: {
    showToast(text, icon, duration) {
      console.log('showToast',text, icon, duration,this);
      this.setData({
        toastShow: !this.data.toastShow,
        toastText: text
      })
      if (!!icon && icon=='success'){
        this.setData({
          icon: icon,
          time: 2000
        })
      }else {
        this.data.time = 2500;
      }
      var that = this

      setTimeout(function () {
        that.setData({
          toastShow: !that.data.toastShow
        })
      }, duration?duration:that.data.time)
    }
  }
})